
<template>
  <div :class="type === 'row' ? 'cshj-button-row' : 'cshj-button-column'" @click="handleClick">
    <i :class="icon"></i>
    <span>{{ title }}</span>
  </div>
</template>

<script>
export default {
  name: 'CshjButton',
  props: {
    title: {
      type: String,
      default: ''
    },
    url: {
      type: String,
      default: ''
    },
    icon: {
      type: String,
      default: 'el-icon-download'
    },
    type: {
      type: String,
      default: 'row'
    },
    position: {
      type: Object,
      default () {
        return {}
      }
    }
  },
  methods: {
    /* eslint-disable */
    handleClick () {
      if (this.position) {
        if (this.position.type === '0') { // 下载登入器

          if (this.position.index === 0) {
            _hmt.push(['_trackEvent', 'software', 'download_drq', '下载登入器'])
            window.open('https://www.lanzous.com/i2fw53c')
          } else if (this.position.index === 1) {
            _hmt.push(['_trackEvent', 'software', 'download_drq', '下载登入器'])
            window.open('http://cshj180.oss-cn-shenzhen.aliyuncs.com/%E5%88%9B%E4%B8%96%E5%90%88%E5%87%BB%5B%E5%90%AB%E6%B8%B8%E6%88%8F%E8%AF%B4%E6%98%8E%5D.zip')
          } else if (this.position.index === 2) {
            _hmt.push(['_trackEvent', 'software', 'download_cp', '完整补丁下载'])
            window.open('https://www.lanzous.com/i2fg4vi')
          } else {
            _hmt.push(['_trackEvent', 'software', 'download_cp', '完整补丁下载'])
            window.open('https://www.lanzous.com/i2fg4vi')
          }
        } else if (this.position.type === '1') { // 下载补丁
          _hmt.push(['_trackEvent', 'software', 'download_patch', '下载补丁'])

          if (this.position.index === 0 || this.position.index === 1) { // 纯净客户端、完整客户端
            window.open('https://pan.baidu.com/s/1dFE7GcD')
          } else if (this.position.index === 2 || this.position.index === 3) {
            window.open('https://www.lanzous.com/i2fg4vi')
          } else if (this.position.index === 9) { // 网通IP加速补丁
            window.open('http://www.27net.net/')
          } else {
            window.open('https://www.lanzous.com/b493322/')
          }
        } else if (this.position.type === '2') { // QQ

          if (this.position.index === 0) { // 咨询客服
            _hmt.push(['_trackEvent', 'QQ', 'service', '咨询客服'])
            window.open('http://wpa.qq.com/msgrd?v=3&uin=2384049697&site=qq&menu=yes')
          } else if (this.position.index === 1) { // 值班技术
            _hmt.push(['_trackEvent', 'QQ', 'skill', '值班技术'])
            window.open('http://wpa.qq.com/msgrd?v=3&uin=1520637613&site=qq&menu=yes')
          } else if (this.position.index === 2) { // 担保客服
            _hmt.push(['_trackEvent', 'QQ', 'guarantees', '担保客服'])
            window.open('http://wpa.qq.com/msgrd?v=3&uin=200740237&site=qq&menu=yes')
          } else if (this.position.index === 3) { // 创世交流
            _hmt.push(['_trackEvent', 'QQ', 'join_QQ', '加入创世交流群'])
            window.open('https://jq.qq.com/?_wv=1027&k=587TANd')
          }
        }
      }
    }
  }
}
</script>

<style scoped lang="scss">
.cshj-button-row {
  cursor: pointer;
  display: flex;
  align-items: center;
  height: 52px;
  width: 130px;
  border-bottom: 1px solid $border;
  justify-content: center;
  color: $white;
  &:hover {
    color: $font-color-active;
  }
  i {
    margin-right: 4px;
  }
}
.cshj-button-column {
  cursor: pointer;
  display: flex;
  flex-direction: column;
  justify-content: center;
  height: 100px;
  align-items: center;
  border-bottom: 1px solid $border;
  border-right: 1px solid $border;
  width: 50%;
  color: $white;
  &:hover {
    color: $font-color-active;
  }
  span {
    font-size: 12px;
    width: 54px;
    line-height: 16px;
    text-align: center;
  }
  i {
    font-size: 30px;
  }
}
</style>
